<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/sks/cms/page/share/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="租房,买房,三棵松,地产,中介" />
<meta name="description" content="三棵松地产" />
<title>三棵松地产</title>
<script type="text/javascript" src="/js/jquery-1.3.1.min.js"></script>
<%@ include file="/sks/cms/page/share/validate.inc"%>
<script type="text/javascript">
	function bodyOnLoad() {
		var f1 = new tt.Field("内容", "", "content").setMsgId("errorId");
		new tt.LV().set(0, 1000).add(f1);
		var f2 = new tt.Field("联系方式", "", "linkInfo").setMsgId("linkInfoErrorId");
		new tt.LV().set(0,100).add(f2);
	};

	$(document).ready( function() {

		$('#randCodeImage').click(function(){
			$('#randCodeImage').hide().attr('src','/sks/rand.do?'+ Math.floor(Math.random()* 100 ) ).fadeIn();
		});
		
		$('#submitMessageBtn').click( function() {
			var val = $('#content').val();
			var randCodeVal = $('#randCode').val();
			if (!val || $.trim(val) == "") {
				alert("请输入留言信息！");
			}else if(!randCodeVal || $.trim(randCodeVal)==""){
				alert("请输入验证码！");	
			}else {

			var params = $('#messageForm').serialize();
			$.ajax( {
				url :"/sks/message.do?method=add",
				data :params,
				dataType :'json',
				type :'post',
				timeout :20000,
				success : function(data) {
					//var dataObj = eval("(" + data + ")");
					var dataObj = data;
					if (dataObj.result == "success") {
						$('#content').attr("value","");
						$('#randCode').attr("value","");
						$('#randCodeImage').hide().attr('src','/sks/rand.do?'+ Math.floor(Math.random()* 100 ) ).fadeIn();
						alert("留言已经成功提交，我们的经纪人会主动联系您的！");
					} else if (dataObj.result == "failed") {
						if (dataObj.message) {
							alert(dataObj.message);
						} else {
							alert("提交留言失败！");
						}
					}
				},
				error : function() {
					alert("提交请求发送失败！");
				}
			});

			}
		});
	});
</script>
</head>
<body onload="bodyOnLoad();">
<div class="wrap"><jsp:include page="../header.jsp"></jsp:include>
<div>
<div><a href="<%=basePath%>" hidefocus="true">SKS房地产</a> &gt;
	<c:if test="${!empty users}"> 
	<a href="<%=basePath%>sks/frontpages/privilege/deployment/list.do" target="_self" hidefocus="true">个人中心</a> &gt;
	</c:if>
	留言
</div>
<div class="clear"></div>
</div>
<br>
<center>
<html:form styleId="messageForm"
	action="/sks/message.do?method=add">
	
	<html:textarea
		style="height: 230px; width: 560px; border:1px solid #CCCCCC;"
		property="content" styleId="content"></html:textarea>
	<html:errors property="content" />
	<div id="errorId" style="width: 30%;"></div>
	<br>
	<div style="text-align: left; margin-left: 30%;">
		<div style="float: left;">
		联系方式：				
		<html:text  property="linkInfo" styleId="linkInfo" ></html:text>
		<html:errors property="linkInfo" />
		</div>
		<div style="float: left;" id="linkInfoErrorId" style="width: 48%;"></div>
		<br><br>
		验证图片：
		<img id="randCodeImage" src="/sks/rand.do"
			height="30px"
			border="0" alt="请输入此验证码，如看不清请点击刷新。" style="cursor: pointer; background: #FFF; border: 0; padding: 0;" />
		&nbsp;看不清请点击图片刷新
	    <br><br>
		&nbsp;&nbsp;&nbsp;验证码：
		<input type="text" name="randCode" id="randCode" />&nbsp;请输入上图中字符，大小写忽略
	</div>
	<br>
	<input id="submitMessageBtn" type="button" value="提交"
		style="width: 100px;cursor: pointer;" />
</html:form>
</center>
<br>
<!-- footer starts here --> <jsp:include page="../rooster.jsp"></jsp:include>
<!-- footer ends here --></div>
</body>
</html>